/**    
* @Title: RoleController.java  
* @Package com.kaver.sso.web.controller.rest   
* @author roc   
* @date Aug 6, 2021 4:21:00 PM  
* @version V1.0  
* @copyright kaver 
*/
package com.kaver.sso.web.controller.rest;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.kaver.sso.def.Result;
import com.kaver.sso.def.dto.RoleDto;
import com.kaver.sso.def.req.AddRoleReq;
import com.kaver.sso.def.req.DelRoleReq;
import com.kaver.sso.def.req.RoleListReq;
import com.kaver.sso.def.req.RolePageListReq;
import com.kaver.sso.def.req.SetRoleReq;
import com.kaver.sso.def.req.UpdateRoleReq;
import com.kaver.sso.def.resp.PageResp;
import com.kaver.sso.service.RoleService;

/**  
* @ClassName: RoleController  
* @Description: 角色
* @author roc  
* @date Aug 6, 2021 4:21:00 PM  
*    
*/
@RestController
@RequestMapping("/api/role")
public class RoleController {
    @Autowired
    RoleService roleService;
    /**
     * 添加角色
     */
    @PostMapping("/addRole")
    public Result<Void> addRole(@RequestBody AddRoleReq req) {
        roleService.addRole(req);
        return Result.createSuccess();
    }
    
    /**
     * 删除角色
     */
    @PostMapping("/delRole")
    public Result<Void> delRole(@RequestBody DelRoleReq req) {
        roleService.delRole(req);
        return Result.createSuccess();
    }
    /**
     * 更新角色
     */
    @PostMapping("/updateRole")
    public Result<Void> updateRole(@RequestBody UpdateRoleReq req) {
        roleService.updateRole(req);
        return Result.createSuccess();
    }
    
    /**
     * 角色列表分页查询
     */
    @PostMapping("/rolePageList")
    public Result<PageResp<RoleDto>> rolePageList(@RequestBody RolePageListReq req) {
        return Result.createSuccess(roleService.rolePageList(req));
    }
    /**
     * 角色列表查询
     */
    @PostMapping("/roleList")
    public Result<List<RoleDto>> roleList(@RequestBody RoleListReq req) {
        return Result.createSuccess(roleService.roleList(req));
    }
    /**
     * 用户设置角色
     */
    @PostMapping("/setRole")
    public Result<Void> setRole(@RequestBody SetRoleReq req) {
        roleService.setRole(req);
        return Result.createSuccess();
    }
}
